﻿package base
{
    import com.dusk.tool.ColorMatrix;
    import com.dusk.util.RandomUtil;
    import com.dusk.util.ResUtil;
    import com.dusk.util.TextUtil;
    import com.dusk.util.UtilBase;
    import com.game.ctrler.GameKeyInput;
    import com.game.data.constant.AddEffectType;
    import com.game.data.constant.FrameRate;
    import com.game.data.constant.HitType;
    import com.game.data.vo.EquipmentVO;
    import com.game.data.vo.GameGadgetVO;
    import com.game.data.vo.HitResultVO;
    import com.game.data.vo.HitVO;
    import com.game.data.vo.PetDataVO;
    import com.game.data.vo.PlayerDataVO;
    import com.game.data.vo.attribute.RoleAttribVO;
    import com.game.engine.MainGame;
    import com.game.engine.nape.BodyTypeConst;
    import com.game.engine.nape.utils.CBTypes;
    import com.game.engine.nape.utils.CollisionGroup;
    import com.game.engine.phys.RigidBody;
    import com.game.engine.phys.Vector2D;
    import com.game.event.GameEventType;
    import com.game.manager.AnimationManager;
    import com.game.manager.EventManager;
    import com.game.manager.SoundManager;
    import com.game.view.component.AccumulatePowerBar
    import com.game.view.component.GameGadgetType;
    import com.game.view.component.TransDoor;
    import com.game.view.display.AnimationClip;
    import com.game.view.display.AnimationLoopType;
    import com.greensock.TweenMax;
    
    import export.bullet.FollowTargetBullet;
    import export.hero.Role1;
    
    import flash.display.Bitmap;
    import flash.display.DisplayObject;
    import flash.display.MovieClip;
    import flash.events.KeyboardEvent;
    import flash.filters.ColorMatrixFilter;
    import flash.geom.Point;
    import flash.utils.getTimer;
    
    public class BaseHero extends BaseObject
    {
        
        public function BaseHero()
        {
            protectedEquipObject = {"curClothId1": 0, "curClothId2": 0, "curWeaponId1": 0, "curWeaponId2": 0};
            super();
            roleProperties = new RoleAttribVO(this);
            attackBackInfoDict["hitNiumowangSzBuff"] = {
                "hitMaxCount": 100,
                "attackBackSpeed": [-5, 0],
                "attackInterval": 24,
                "attackKind": "magic",
                "addprotection": 2
            };
            attackBackInfoDict["hitZhuanlunwangSzBuff"] = {
                "hitMaxCount": 100,
                "attackBackSpeed": [0, 0],
                "attackInterval": 999,
                "attackKind": "magic",
                "addEffect": [{"name": BaseAddEffect.STUN, "time": gc.frameClips * 5}],
                "addprotection": 2
            };
            attackBackInfoDict["hitTiantingZhanshenSzBuff"] = {
                "hitMaxCount": 100,
                "attackBackSpeed": [0, 0],
                "attackInterval": 999,
                "attackKind": "magic",
                "addEffect": [{"name": BaseAddEffect.TIANTINGZHANSHEN, "time": gc.frameClips * 2}],
                "addprotection": 2
            };
            attackBackInfoDict["fabao-sword"] = {
                "hitMaxCount": 999,
                "attackBackSpeed": [0, 0],
                "attackInterval": 999,
                "attackKind": "magic",
                "addprotection": 0
            };
            attackBackInfoDict["magicsword2"] = {
                "hitMaxCount": 999,
                "attackBackSpeed": [0, 0],
                "attackInterval": 2,
                "attackKind": "magic",
                "addprotection": 0
            };
            attackBackInfoDict["Pearl"] = {
                "hitMaxCount": 999,
                "attackBackSpeed": [-1, -3],
                "attackInterval": 999,
                "attackKind": "magic",
                "addprotection": 0
            };
            attackBackInfoDict["fabao-pearl"] = {
                "hitMaxCount": 999,
                "attackBackSpeed": [2, -2],
                "attackInterval": 2,
                "attackKind": "magic",
                "addprotection": 0
            };
            attackBackInfoDict["fabao-snow"] = {
                "hitMaxCount": 999,
                "attackBackSpeed": [2, -2],
                "attackInterval": 999,
                "attackKind": "magic",
                "addprotection": 0,
                "addEffect": [{"name": BaseAddEffect.ICE, "time": gc.frameClips * 3}]
            };
        }
        
        public var roleProperties:RoleAttribVO;
        protected var allianceBitmap:Bitmap;
        protected var protectedEquipObject:Object;
        protected var canNextAction:Boolean = true;
        protected var exceedPowerSprite:AccumulatePowerBar;
        protected var normalAttackNum:uint = 0;//记录普通攻击的段数
        protected var player:PlayerDataVO;
        protected var myPet:BasePet;
        protected var keyInput:GameKeyInput;
        
        override protected function onFirstAdded():void
        {
        }
        
        override protected function turnToGXP():void
        {
            var _loc1_:* = null;
            var _loc2_:int = 0;
            var _loc3_:* = null;
            isGXP = true;
            gravity = 3.75;
            horizonSpeed = int(int(horizonSpeed * 1.5));
            horizonRunSpeed = int(int(horizonRunSpeed * 1.5));
            jumpPower = int(int(jumpPower * 1.5));
            _loc1_ = getPlayer().getCurEquipByType("zbsz");
            if (_loc1_)
            {
                if (_loc1_.equipId == "yxnmwsz" || _loc1_.equipId == "jlnmwsz" || _loc1_.equipId == "ssnmwsz")
                {
                    _loc2_ = 1;
                    if (_loc1_.equipId == "yxnmwsz")
                    {
                        _loc2_ = 1;
                    }
                    else if (_loc1_.equipId == "jlnmwsz")
                    {
                        _loc2_ = 2;
                    }
                    else if (_loc1_.equipId == "ssnmwsz")
                    {
                        _loc2_ = 3;
                    }
                    _loc3_ = new FollowTargetBullet("PetMonkey1Bullet2");
                    if (getBBDC().getDirect() == 0)
                    {
                        _loc3_.x = x - 50;
                    }
                    else
                    {
                        _loc3_.x = x + 50;
                    }
                    _loc3_.y = y - 60;
                    _loc3_.setRole(this);
                    _loc3_.setDestroyWhenLastFrame(false);
                    _loc3_.setHurtCanCutDownEffect(false);
                    _loc3_.setDestroyInCount(gc.frameClips * 12);
                    _loc3_.setDirect(getBBDC().getDirect());
                    _loc3_.setAction("hitNiumowangSzBuff");
                    gc.gameScene.addChild(_loc3_);
                    magicBulletArray.push(_loc3_);
                }
                else if (_loc1_.equipId == "yxzlwsz" || _loc1_.equipId == "jlzlwsz" || _loc1_.equipId == "sszlwsz")
                {
                    _loc2_ = 1;
                    if (_loc1_.equipId == "yxzlwsz")
                    {
                        _loc2_ = 1;
                    }
                    else if (_loc1_.equipId == "jlzlwsz")
                    {
                        _loc2_ = 2;
                    }
                    else if (_loc1_.equipId == "sszlwsz")
                    {
                        _loc2_ = 3;
                    }
                    attackBackInfoDict["hitZhuanlunwangSzBuff"] = {
                        "hitMaxCount": 100,
                        "attackBackSpeed": [0, 0],
                        "attackInterval": 999,
                        "attackKind": "magic",
                        "addEffect": [{"name": BaseAddEffect.STUN, "time": gc.frameClips * (2 + _loc2_)}],
                        "addprotection": 2
                    };
                    _loc3_ = new FollowTargetBullet("ZhuanLunWangSzEffect");
                    _loc3_.x = x;
                    _loc3_.y = y;
                    _loc3_.setRole(this);
                    _loc3_.setDirect(getBBDC().getDirect());
                    _loc3_.setAction("hitZhuanlunwangSzBuff");
                    gc.gameScene.addChild(_loc3_);
                    magicBulletArray.push(_loc3_);
                }
                else if (_loc1_.equipId == "yxsmsrsz" || _loc1_.equipId == "jlsmsrsz" || _loc1_.equipId == "sssmsrsz")
                {
                    _loc2_ = 1;
                    if (_loc1_.equipId == "yxsmsrsz")
                    {
                        _loc2_ = 1;
                    }
                    else if (_loc1_.equipId == "jlsmsrsz")
                    {
                        _loc2_ = 2;
                    }
                    else if (_loc1_.equipId == "sssmsrsz")
                    {
                        _loc2_ = 3;
                    }
                    curAddEffect.addEffects([{
                        "name": BaseAddEffect.CURE_AFTER_KILL_MONSTER,
                        "time": gc.frameClips * 10,
                        "hurt": roleProperties.atk * _loc2_ / 4
                    }]);
                }
                else if (_loc1_.equipId == "yxttzssz" || _loc1_.equipId == "jlttzssz" || _loc1_.equipId == "ssttzssz")
                {
                    _loc2_ = 1;
                    if (_loc1_.equipId == "yxttzssz")
                    {
                        _loc2_ = 1;
                    }
                    else if (_loc1_.equipId == "jlttzssz")
                    {
                        _loc2_ = 2;
                    }
                    else if (_loc1_.equipId == "ssttzssz")
                    {
                        _loc2_ = 3;
                    }
                    attackBackInfoDict["hitTiantingZhanshenSzBuff"] = {
                        "hitMaxCount": 100,
                        "attackBackSpeed": [0, 0],
                        "attackInterval": 999,
                        "attackKind": "magic",
                        "addEffect": [{
                            "name": BaseAddEffect.TIANTINGZHANSHEN,
                            "time": gc.frameClips * (_loc2_ * 2)
                        }]
                    };
                    _loc3_ = new FollowTargetBullet("tiantingzhanshenBullet1_1");
                    if (getBBDC().getDirect() == 0)
                    {
                        _loc3_.x = x;
                    }
                    else
                    {
                        _loc3_.x = x;
                    }
                    _loc3_.y = y;
                    _loc3_.setRole(this);
                    _loc3_.setHurtCanCutDownEffect(false);
                    _loc3_.setDirect(getBBDC().getDirect());
                    _loc3_.setAction("hitTiantingZhanshenSzBuff");
                    gc.gameScene.addChild(_loc3_);
                    magicBulletArray.push(_loc3_);
                    _loc3_ = new FollowTargetBullet("tiantingzhanshenBullet1_2");
                    if (getBBDC().getDirect() == 0)
                    {
                        _loc3_.x = x;
                    }
                    else
                    {
                        _loc3_.x = x;
                    }
                    _loc3_.y = y;
                    _loc3_.setRole(this);
                    _loc3_.setHurtCanCutDownEffect(false);
                    _loc3_.setDirect(getBBDC().getDirect());
                    _loc3_.setAction("hitTiantingZhanshenSzBuff");
                    gc.gameScene.addChild(_loc3_);
                    magicBulletArray.push(_loc3_);
                }
            }
        }
        
        /**
         * 减少血量，注意会显示血量减少数值
         * @param value 伤害
         */
        override public function reduceHp(value:int = 0):void
        {
            /*if (curAddEffect)
            {
                if (curAddEffect.hasEffect(BaseAddEffect.SHIELD) || curAddEffect.hasEffect(BaseAddEffect.REFLECT_SHIELD))
                {
                    curAddEffect.reduceMagicUmbDef(value);
                    return;
                }
                if (curAddEffect.getEffectByName(BaseAddEffect.PET_TURTLE_BUFF))
                {
                    if (getPet() && getPet().curAddEffect && getPet().curAddEffect.getEffectByName(BaseAddEffect.PET_TURTLE_BUFF))
                    {
                        getPet().reduceHp(Math.ceil(value * 0.05));
                        value *= 0.95;
                        value = Math.ceil(value);
                    }
                }
            }*/
            if (gc.flowerSoul.getSoulLevelByType("def") > 0)
            {
                value *= gc.flowerSoul.getProp_def().key;
            }//花魂减伤
            var i:int = value - roleProperties.hp;
            roleProperties.reduceHp(value);
            if (roleProperties.hp <= 0)
            {//血量低于0
                value -= i;
                if (getPlayer())
                {
                    var equipVO:EquipmentVO = getPlayer().wearEquip.decoration;
                    if (equipVO != null)
                    {
                        if (equipVO.equipId == "shsjt")
                        {
                            roleProperties.hp += roleProperties.hpMax * 0.1 * (equipVO.strengthLevel + 1);
                            doRelive();
                            getPlayer().removeCurEquip(equipVO);
                            return;
                        }
                        if (equipVO.equipId == "dzjj")
                        {
                            if (roleProperties.mp >= value * 3)
                            {
                                reduceMp(value * 3);
                                return;
                            }
                            reduceMp(value * 3);
                        }
                    }
                    equipVO = getPlayer().getCurEquipByType("zbfb");
                    if (equipVO != null)
                    {
                        if (equipVO.equipId == "tjbg")
                        {
                            if (!roleProperties.tjbg_revive)
                            {
                                roleProperties.setFullHp();
                                if (equipVO.hasElement("木"))
                                {
                                    roleProperties.mp += roleProperties.mpMax / 2;
                                }
                                doRelive();
                                roleProperties.tjbg_revive = true;
                                return;
                            }
                        }
                    }
                }
                if (!isAlreadyDead)
                {
                    isAlreadyDead = true;
                    setAction("dead");
                    setInvincible(FrameRate.ANIMATE_FRAME_RATE * 10);
                    var p:Point = getCollideCenter();
                    EventManager.getIns().dispatchEvent(GameEventType.HERO_DEAD, {x: p.x, y: p.y});
                    destroy();
                }
            }
        }
        
        override public function isIdle():Boolean
        {
            return curAction == "idle" || curAction == "idle2";
        }
        
        override public function hit(bul:BaseBullet, target:BaseObject, result:HitResultVO):void
        {
            if (getAttribute().bloodThirst > 0)
            {
                cureHp(getAttribute().bloodThirst * result.hurt / 100);
            }
            var vo:HitVO = bul.hitVO;
            if (vo.addEnergy > 0 && vo.addEnergyMax > 0 && _framer - timerDict.lastAddEnergy > 5 && !isGXP)
            {
                if (vo.addEnergyMax > vo.addEnergy)
                {
                    getAttribute().energy += bul.hitVO.addEnergy;
                    bul.hitVO.addEnergyMax -= bul.hitVO.addEnergy;
                }
                else
                {
                    getAttribute().energy += bul.hitVO.addEnergyMax;
                }
                timerDict.lastAddEnergy = _framer;
            }
        }
        
        override public function beHit(bul:BaseBullet, target:BaseObject):HitResultVO
        {
            var result:HitResultVO = new HitResultVO();
            var vo:HitVO = bul.hitVO;
            result.hitType = vo.hitType;
            if (isDead())
            {
                result.success = false;
                return result;
            }
            if (isInvincible() && !vo.isEnforceHit)
            {
                result.success = false;
                return result;
            }
            if (vo.isCanBeMiss && RandomUtil.randBoolean(getMiss() - target.getHit()))
            {
                result.success = false;
                result.isMiss = true;
                addHurtNumber(result);
                if (gc.flowerSoul.getSoulLevelByType("miss") > 0)
                {
                    var data:Object = gc.flowerSoul.getProp_miss();
                    if (RandomUtil.randBoolean(data.odds * 100))
                    {
                        target.reduceHp(getAtk() * data.rate);
                        gc.vController.shine();
                    }
                }//闪避后反击
                return result;
            }
            if (vo.isBingo)
            {
                reduceHp(getHpMax());
                reduceMp(getMpMax());
                setInvincible(FrameRate.ANIMATE_FRAME_RATE);
                result.success = true;
                result.isBingo = true;
                bul.setHurt(getHpMax() * 2);
            }
            var attackBack:Point = getAttackBackSpeed(bul, vo);
            if (!isSteelBody() && !isGXP)
            {
                setAttackBack(attackBack);
                keyInput.cancelRun();
                setAction("hurt");
                setStiff(vo.stiffTime);
            }
            if (vo.addEffect.length)
            {
                var copy:Array = UtilBase.clone(vo.addEffect) as Array;
                for each (var item:Object in copy)
                {
                    if (item.time == 0)
                    {
                        item.time = bul.getFrameLeft();
                    }
                }
                addCurAddEffect(copy);
            }
            var isCrit:Boolean = RandomUtil.randBoolean(target.getCrit() - getToughness());
            var critDmg:Number = ((100 + target.getCritDamage() - getDeCritDamage()) / 100) * 1.5;
            critDmg = Math.max(critDmg, 1.5);
            var hurt:int = bul.getHurt() * (isCrit ? critDmg : 1);
            hurt = calculateHurt(hurt, bul.hitVO, target);
            reduceHp(hurt);
            if (bul.getBulletName() == "Monster1005Bullet2Over")
            {
                gc.pWorld.getBaseLevelListener().startBlackBG();
                TweenMax.delayedCall(10, function ():*
                {
                    gc.pWorld.getBaseLevelListener().stopBlackBG();
                });
            }//障目效果
            /*if (gc.flowerSoul.getSoulLevelByType("atk") > 0)
            {
                var data:Object = gc.flowerSoul.getProp_atk();
                if (RandomUtil.randBoolean(data.odds * 100))
                {
                    addCurAddEffect([{
                        "name": BaseAddEffect.TIANTINGZHANSHEN,
                        "time": gc.frameClips * data.duration
                    }]);
                }
            }//花魂破防*/
            resetGravity();
            addBeAttackEffect();
            if (!timerDict.lastBeAttackTime)
            {
                timerDict.lastBeAttackTime = int.MIN_VALUE;
            }
            if (_framer - timerDict.lastBeAttackTime > 5)
            {
                beAttackedTimes += vo.addProtection;
                timerDict.lastBeAttackTime = _framer;
            }
            if (beAttackedTimes > 19)
            {
                setInvincible(FrameRate.ANIMATE_FRAME_RATE * 3, true);
                beAttackedTimes = 0;
            }
            /*switch (player.roleId)
            {
                case 1:
                case 4:
                    SoundManager.playSound("Role1_beAttack");
                    break;
                case 2:
                    SoundManager.playSound("Role2_beAttack");
                    break;
                case 3:
                    SoundManager.playSound("Role3_beAttack");
                    break;
            }*/
            result.success = true;
            result.hurt = hurt;
            result.isCrit = isCrit;
            result.isMiss = false;
            addHurtNumber(result);
            return result;
        }
        
        override public function beMagicAttack(param1:BaseBullet, param2:BaseObject, param3:Boolean = false):Boolean
        {
            return super.beMagicAttack(param1, param2, true);
            /*var bb:* = undefined;
            var _loc5_:int = 0;
            var _loc6_:int = 0;
            var _loc7_:* = null;
            var _loc8_:* = null;
            if (isInvincible())
            {
                return false;
            }
            if (param1.hitVO.isEnforceHit || checkCollideRect(param1.getCollideArea()))
            {
                if (RandomUtil.randBoolean(getMiss() - param2.getHit()))
                {
                    addMissMc();
                    if (gc.flowerSoul.getSoulLevelByType("miss") > 0)
                    {
                        var data:Object = gc.flowerSoul.getProp_miss();
                        if (RandomUtil.randBoolean(data.odds * 100))
                        {
                            param2.reduceHp(getAtk() * data.rate);
                            gc.vController.shine();
                        }
                    }//闪避后反击
                    return true;
                }
                if (param1.hitVO.isBingo)
                {
                    var vo:GameGadgetVO = new GameGadgetVO(GameGadgetType.BINGO, new Point(x, y));
                    EventManager.getIns().dispatchEvent(GameEventType.ADD_GAME_GADGET, vo);
                    reduceHp(getHpMax() * 0.5, true);
                    reduceMp(getMpMax() * 0.1);
                    setInvincible(gc.frameClips);
                    return true;
                }//bingo逻辑
                _loc5_ = param1.getHurt();
                _loc7_ = param2.attackBackInfoDict[param1.curAction];
                isCrit = param1.isCrit;
                if (isCrit && RandomUtil.randBoolean(getToughness()))
                {
                    _loc5_ *= 0.5;
                    isCrit = false;
                }
                for each (bb in magicBulletArray)
                {
                    if (bb.getImcName() == "MagicFlagEffect")
                    {
                        param2.addCurAddEffect([{"name": BaseAddEffect.MAGIC_FLAG_DEBUFF, "time": gc.frameClips * 5}]);
                    }
                }
                _loc6_ = countHurt(_loc5_, param2.getDeMagicDef(), _loc7_);
//				if (this is Role3)
//				{
//					if (curAction == "hit12")
//					{
//						param2.reduceHp(_loc6_ * 5);
//						if (getPlayer().returnSkillLevelBySkillName("tmc") == 10)
//						{
//							_loc6_ *= 0.5;
//						}
//					}
//					if (getPlayer())
//					{
//						if (getPlayer().findSkillIsInTheSkillAry("rj"))
//						{
//							if (Math.random() <= 0.1 + getPlayer().returnSkillLevelBySkillName("rj") * 0.005)
//							{
//								cureHp(getAtk() * 0.8);
//							}
//						}
//					}
//				}
                if (param1.getBulletName() == "Role1Bullet12")
                {
                    reduceHp(_loc6_, false);
                }//火眼金睛不击退
                else
                {
                    reduceHp(_loc6_, true);
                }//击退
                /!*else if (param2 is Monster6)
                {
                    if (Math.random() <= 0.25)
                    {
                        if (curAddEffect)
                        {
                            curAddEffect.add([{"name": BaseAddEffect.PETHORSE_ICE, "time": gc.frameClips * 2}]);
                        }
                    }
                }
                else if (param2 is Monster16)
                {
                    if (Math.random() <= 0.25)
                    {
                        if (curAddEffect)
                        {
                            curAddEffect.add([{
                                "name": BaseAddEffect.PETMONKEY_FIRE,
                                "hurt": 40,
                                "time": gc.frameClips * 5
                            }]);
                        }
                    }
                }//广目天王攻击灼烧
                else if (param2 is Monster34)
                {
                    if (_loc7_ && _loc7_.attackKind == "physics")
                    {
                        Monster34(param2).cureHp(_loc6_ * 0.05);
                    }
                }//邪悟空攻击吸血
                else if (param2 is Monster1007)
                {
                    if (param2.curAddEffect)
                    {
                        if (param2.curAddEffect.curDebuff(BaseAddEffect.LEMHXX))
                        {
                            Monster1007(param2).cureHp(_loc6_ * 20);
                        }
                    }
                }//六耳猕猴攻击吸血*!/
                _loc8_ = getAttackBackSpeed(param1, _loc7_);
                if (curAddEffect)
                {
                    if (curAddEffect.hasEffect(BaseAddEffect.REFLECT_SHIELD))
                    {
                        param2.reduceHp(_loc6_ * 2);
                    }
                }//混元无极伞反伤
                if (param1.getBulletName() != "Role1Bullet12")
                {
                    setAttackBack(_loc8_);
                }//执行击退逻辑
                if (param1.getBulletName() == "Monster1005Bullet2Over")
                {
                    gc.pWorld.getBaseLevelListener().startBlackBG();
                    TweenMax.delayedCall(10, function ():*
                    {
                        gc.pWorld.getBaseLevelListener().stopBlackBG();
                    });
                }//障目效果
                if (_loc7_.addEffect)
                {
                    for each (var singleAddEffect:Object in _loc7_.addEffect)
                    {
                        if (singleAddEffect != null && singleAddEffect.time == BaseBullet.DESIDE_BY_FRAMES_LEFT)
                        {
                            singleAddEffect.time = param1.getFrameLeft();
                        }
                    }
                    addCurAddEffect(_loc7_.addEffect);
                }
                beAttackDoing();
                if (this is Role1)
                {
                    SoundManager.playSound("Role1_beAttack");
                }
//				else if (this is Role2)
//				{
//					SoundManager.playSound("Role2_beAttack");
//				}
//				else if (this is Role3)
//				{
//					SoundManager.playSound("Role3_beAttack");
//				}
//				else if (this is Role4)
//				{
//					SoundManager.playSound("Role3_beAttack");
//				}
                return true;
            }
            return false;*/
        }
        
        override protected function addBeAttackEffect():void
        {
            if (_framer - timerDict.lastAddBeHitEffect < 4)
            {
                return;
            }
            var eff:AnimationClip = AnimationManager.getAnimationClip("HeroBeHurt");
            eff.loopType = AnimationLoopType.REMOVE_WHEN_END;
            eff.x = getLocalCollideCenter().x;
            eff.y = getLocalCollideCenter().y;
            effectContainer.addChild(eff);
            timerDict.lastAddBeHitEffect = _framer;
        }
        
        override public function isAttacking():Boolean
        {
            return false;
        }
        
        override public function isWalkOrRun():Boolean
        {
            return curAction == "walk" || isRunning();
        }
        
        override public function resetGravity():void
        {
            super.resetGravity();
        }
        
        override public function render(ratio:Number = 1):void
        {
            super.render(ratio);
            //调整位置
            var curP:Point = gc.gameScene.localToGlobal(new Point(x, y));
            var tarP:Point = gc.gameScene.globalToLocal(new Point(20, 0));
            if (curP.x < 20)
            {
                x = tarP.x;
            }
            else if (curP.x > 920)
            {
                x = tarP.x + 900;
            }
        }
        
        override public function renderAnimate():void
        {
            super.renderAnimate();
            if (isInvincible())
            {
                alpha = isTransparent ? 0.7 : 1;
            }
            else
            {
                alpha = 1;
            }
            updateOther();
            if (isInSky() && curAction == "jump1" && velocity.y > 0)
            {
                setAction("jump3");
            }
            setPet();
            updateEquip();
            updateMagicWeapon();
        }
        
        override protected function isCannotMoveWhenAttack():Boolean
        {
            return false;
        }
        
        override protected function isRunning():Boolean
        {
            return keyInput.isRunLeft() || keyInput.isRunRight();
        }
        
        override protected function jump():void
        {
            if (isAttacking() || isBeAttacking())
            {
                return;
            }
            if (jumpCount < 2)
            {
                velocity.y = jumpPower;
                if (jumpCount == 0)
                {
                    jumpCount = 1;
                    setAction("jump1");
                }
                else if (bbdc.getAction() == "jump1" && getTimer() - timerDict.lastJumpTime < 150)
                {
                    jumpCount = 1;
                }
                else
                {
                    jumpCount = 2;
                    setAction("jump2");
                }
            }
            else if (jumpCount == 2)
            {
                if (MainGame.getIns().isInSea())
                {
                    velocity.y = jumpPower;
                    setAction("jump2");
                }
            }
            timerDict.lastJumpTime = getTimer();
        }
        
        override protected function updatePosition(ratio:Number = 1):void
        {
            var t:Number = 1;
            if (curAddEffect)
            {
                if (curAddEffect.isCannotControlSkill())
                {
                    return;
                }
                if (curAddEffect.getEffectByType(AddEffectType.SPEED_DOWN) != null)
                {
                    t *= curAddEffect.getEffectByType(AddEffectType.SPEED_DOWN).value;
                }
                if (curAddEffect.getEffectByType(AddEffectType.SPEED_UP) != null)
                {
                    t *= curAddEffect.getEffectByType(AddEffectType.SPEED_UP).value;
                }
            }
            if (standInObj)
            {
                if (isIdle())
                {
                    velocity.x = standInObj.velocity.x;
                }
            }
            if (MainGame.getIns().isInSea())
            {
                t *= 0.7;
                velocity.x = velocity.x > 8 ? 8 : velocity.x;
                velocity.y = velocity.y > 16 ? 16 : velocity.y;
            }
            velocity.x *= t;
            velocity.y *= t;
            super.updatePosition(ratio);
            if (getDefiniteCollideArea().left < 0)
            {
                x += -getDefiniteCollideArea().left;
            }
            if (getDefiniteCollideArea().right > 940)
            {
                x += 940 - getDefiniteCollideArea().right;
            }
        }
        
        override protected function checkOver():void
        {
            if (y >= 1500)
            {
                reduceHp((roleProperties.hpMax + roleProperties.mpMax) * 20);
            }
        }
        
        public function getAttribute():RoleAttribVO
        {
            return roleProperties;
        }
        
        /**
         * 判断角色是否死亡
         * @return
         */
        override public function isDead():Boolean
        {
            return roleProperties.hp <= 0;
//			var equip:EquipmentVO;
//			if (player)
//			{
//				equip = player.getCurEquipByType("zbsp");
//				if (equip)
//				{
//					if (equip.equipId == "dzjj")
//					{
//						return roleProperties.hp <= 0 && roleProperties.mp <= 0;
//					}
//				}
//				return roleProperties.hp <= 0;
//			}
//			return true;
        }
        
        override public function setStatic():void
        {
            super.setStatic();
            keyInput.cancelRun();
        }
        
        override public function isNormalHit():Boolean
        {
            return true;
        }
        
        override public function getHpMax():int
        {
            return roleProperties.hpMax;
        }
        
        override public function getHp():int
        {
            return roleProperties.hp;
        }
        
        override public function getMpMax():int
        {
            return roleProperties.mpMax;
        }
        
        override public function getMp():int
        {
            return roleProperties.mp;
        }
        
        override public function getAtk():int
        {
            var critUp:* = 1;
            var num:Number;
            /*if (curAddEffect)
            {
                if (curAddEffect.getEffectByType(BaseAddEffect.LXFB_BUFF) || curAddEffect.getEffectByType(BaseAddEffect.YXFB_BUFF))
                {
                    critUp += 0.5;
                }
            }*/
            if (gc.flowerSoul.getSoulLevelByType("hp") > 0)
            {
                var soulObj:Object = gc.flowerSoul.getProp_hp();
                num = (1 - (getHp() / getHpMax())) * soulObj.rate;
                critUp += num > soulObj.treshold ? soulObj.treshold : num;
            }
            if (gc.flowerSoul.getSoulLevelByType("crit") > 0)
            {
                soulObj = gc.flowerSoul.getProp_crit();
                if (getCrit() > soulObj.treshold)
                {
                    num = (getCrit() - soulObj.treshold) * 0.01 * soulObj.rate;
                    critUp += num;
                }
            }
            return roleProperties.atk * critUp;
        }
        
        override public function getDef():int
        {
            return roleProperties.def;
        }
        
        override public function getCrit():int
        {
            var critUp:Number = 1;
            /*if (curAddEffect != null)
            {
                if (curAddEffect.getEffectByType(BaseAddEffect.YXFB_BUFF) != null)
                {
                    critUp *= 2;
                }
            }*/
            if (curAddEffect.hasEffect(AddEffectType.ROLE1_SKILL_HYJJ))
            {
                critUp *= (curAddEffect.getEffectByType(AddEffectType.ROLE1_SKILL_HYJJ).value + 100) / 100;
            }
            return roleProperties.crit * critUp;
        }
        
        override public function getToughness():int
        {
            return roleProperties.toughness;
        }
        
        override public function getMiss():int
        {
            return roleProperties.miss;
        }
        
        override public function getHit():int
        {
            return roleProperties.hit;
        }
        
        override public function getCritDamage():int
        {
            var critUp:Number = 1;
            if (curAddEffect.hasEffect(AddEffectType.ROLE1_SKILL_HYJJ))
            {
                critUp *= (curAddEffect.getEffectByType(AddEffectType.ROLE1_SKILL_HYJJ).value + 100) / 100;
            }
            return roleProperties.critDamage * critUp;
        }
        
        override public function getDeCritDamage():int
        {
            return roleProperties.deCritDamage;
        }
        
        override public function getMagicDef():int
        {
            var defUp:Number = 1;
            /*if (curAddEffect != null)
            {
                if (curAddEffect.getEffectByType(BaseAddEffect.SXFB_BUFF) != null)
                {
                    defUp *= 2;
                }
            }*/
            return roleProperties.magicDef * defUp;
        }
        
        override public function getDeMagicDef():int
        {
            return roleProperties.deMagicDef;
        }
        
        public function start():void
        {
//			initPet();
            initMagicWeapon();
            if (getPlayer())
            {
                refreshAppearance();
                roleProperties.level = player.level;
                initAttribute();
            }
            curAddEffect = new BaseAddEffect(this);
            keyInput = gc.keyboardControl;
            keyInput.addListenFunction(keyInputHandler);
            setAction("idle");
        }
        
        override public function cureHp(value:int = 0):void
        {
            if (isDead())
            {
                return;
            }
            /*if (Boolean(curAddEffect.getEffectByType(BaseAddEffect.FORBID_ADD_HP)) || Boolean(curAddEffect.getEffectByType(BaseAddEffect.MONSTER120DEBUFF)) || Boolean(curAddEffect.getEffectByType(BaseAddEffect.MONSTER129Buff)))
            {
                return;
            }
            if (curAddEffect)
            {
                if (curAddEffect.getEffectByType(BaseAddEffect.PET_TURTLE_BUFF))
                {
                    if (getPet() && getPet().curAddEffect && getPet().curAddEffect.getEffectByType(BaseAddEffect.PET_TURTLE_BUFF))
                    {
                        getPet().cureHp(value * 1.05);
                        value *= 1.05;
                        value = Math.ceil(value);
                    }
                }
            }*/
            if (roleProperties)
            {
                roleProperties.cureHp(value);
            }
            super.cureHp(value);
        }
        
        override public function cureMp(value:int = 0):void
        {
            /*if (Boolean(curAddEffect.getEffectByType(BaseAddEffect.MONSTER42_BLUE)) || Boolean(curAddEffect.getEffectByType(BaseAddEffect.MONSTER120DEBUFF)))
            {
                return;
            }*/
            if (roleProperties)
            {
                roleProperties.cureMp(value);
            }
            super.cureMp(value)
        }
        
        public function reduceMp(value:int):void
        {
            if (roleProperties)
            {
                roleProperties.reduceMp(value);
            }
            var vo:GameGadgetVO = new GameGadgetVO(GameGadgetType.NUM_HERO_HURT_MAGIC, new Point(x, y));
            vo.value = value;
            EventManager.getIns().dispatchEvent(GameEventType.ADD_GAME_GADGET, vo);
        }
        
        public function doWhenLevelUp():*
        {
            var _loc1_:* = null;
            if (getPet())
            {
                _loc1_ = ResUtil.getNewObj("PetLevelUpMc") as MovieClip;
                getPet().addChild(_loc1_);
            }
        }
        
        public function doWhenChangeState():*
        {
            if (getPet())
            {
                changePet();
            }
        }
        
        public function addPetByPi(param1:PetDataVO):BasePet
        {
            return null;
            /*var _loc2_:* = null;
            var _loc3_:String = param1.petName;
            if (_loc3_ == "monkey1")
            {
                _loc2_ = new PetMonkey1(this, param1);
            }
            else if (_loc3_ == "monkey2")
            {
                _loc2_ = new PetMonkey2(this, param1);
            }
            else if (_loc3_ == "monkey3")
            {
                _loc2_ = new PetMonkey3(this, param1);
            }
            else if (_loc3_ == "monkey4")
            {
                _loc2_ = new PetMonkey4(this, param1);
            }
            else if (_loc3_ == "horse1")
            {
                _loc2_ = new PetHorse1(this, param1);
            }
            else if (_loc3_ == "horse2")
            {
                _loc2_ = new PetHorse2(this, param1);
            }
            else if (_loc3_ == "horse3")
            {
                _loc2_ = new PetHorse3(this, param1);
            }
            else if (_loc3_ == "horse4")
            {
                _loc2_ = new PetHorse4(this, param1);
            }
            else if (_loc3_ == "ufo1")
            {
                _loc2_ = new PetKabu1(this, param1);
            }
            else if (_loc3_ == "ufo2")
            {
                _loc2_ = new PetKabu2(this, param1);
            }
            else if (_loc3_ == "ufo3")
            {
                _loc2_ = new PetKabu3(this, param1);
            }
            else if (_loc3_ == "tigress1")
            {
                _loc2_ = new PetTiger1(this, param1);
            }
            else if (_loc3_ == "tigress2")
            {
                _loc2_ = new PetTiger2(this, param1);
            }
            else if (_loc3_ == "tigress3")
            {
                _loc2_ = new PetTiger3(this, param1);
            }
            else if (_loc3_ == "tigress4")
            {
                _loc2_ = new PetTiger4(this, param1);
            }
            else if (_loc3_ == "turtle1")
            {
                _loc2_ = new PetTurtle1(this, param1);
            }
            else if (_loc3_ == "turtle2")
            {
                _loc2_ = new PetTurtle2(this, param1);
            }
            else if (_loc3_ == "turtle3")
            {
                _loc2_ = new PetTurtle3(this, param1);
            }
            else if (_loc3_ == "turtle4")
            {
                _loc2_ = new PetTurtle4(this, param1);
            }
            else if (_loc3_ == "phoenix1")
            {
                _loc2_ = new PetPhoenix1(this, param1);
            }
            else if (_loc3_ == "phoenix2")
            {
                _loc2_ = new PetPhoenix2(this, param1);
            }
            else if (_loc3_ == "phoenix3")
            {
                _loc2_ = new PetPhoenix3(this, param1);
            }
            else if (_loc3_ == "phoenix4")
            {
                _loc2_ = new PetPhoenix4(this, param1);
            }
            else if (_loc3_ == "dragon1")
            {
                _loc2_ = new PetDragon1(this, param1);
            }
            else if (_loc3_ == "dragon2")
            {
                _loc2_ = new PetDragon2(this, param1);
            }
            else if (_loc3_ == "dragon3")
            {
                _loc2_ = new PetDragon3(this, param1);
            }
            else if (_loc3_ == "dragon4")
            {
                _loc2_ = new PetDragon4(this, param1);
            }
            else if (_loc3_ == "rabbit1")
            {
                _loc2_ = new PetRabbit1(this, param1);
            }
            else if (_loc3_ == "rabbit2")
            {
                _loc2_ = new PetRabbit2(this, param1);
            }
            else if (_loc3_ == "rabbit3")
            {
                _loc2_ = new PetRabbit3(this, param1);
            }
            else if (_loc3_ == "rabbit4")
            {
                _loc2_ = new PetRabbit4(this, param1);
            }
            else if (_loc3_ == "roomhorse1")
            {
                _loc2_ = new PetRoomHorse1(this, param1);
            }
            else if (_loc3_ == "roomhorse2")
            {
                _loc2_ = new PetRoomHorse2(this, param1);
            }
            else if (_loc3_ == "roomhorse3")
            {
                _loc2_ = new PetRoomHorse3(this, param1);
            }
            else if (_loc3_ == "roomhorse4")
            {
                _loc2_ = new PetRoomHorse4(this, param1);
            }
            else if (_loc3_ == "mouse1")
            {
                _loc2_ = new PetMouse1(this, param1);
            }
            else if (_loc3_ == "mouse2")
            {
                _loc2_ = new PetMouse2(this, param1);
            }
            else if (_loc3_ == "mouse3")
            {
                _loc2_ = new PetMouse3(this, param1);
            }
            else if (_loc3_ == "mouse4")
            {
                _loc2_ = new PetMouse4(this, param1);
            }
            return _loc2_;*/
        }
        
        public function doRelive():void
        {
            var bb:FollowTargetBullet = new FollowTargetBullet("HeroReLive");
            bb.x = x;
            bb.y = y;
            bb.setOwner(this);
            bb.setDirect(0);
            bb.setDisable();
            bb.setAction("relive");
            gc.gameScene.addChild(bb);
            magicBulletArray.push(bb);
            setInvincible(gc.frameClips * 2);
        }
        
        public function getCurMagicWeapon():BaseMagicWeapon
        {
            return curMagicWeapon;
        }
        
        public function updateMagicWeapon():void
        {
            if (curMagicWeapon)
            {
                curMagicWeapon.step();
            }
        }
        
        public function updatePet():void
        {
            if (myPet)
            {
                myPet.step();
            }
        }
        
        public function clearPet():void
        {
            myPet = null;
        }
        
        public function stepSkillKey():void
        {
            if (isDead())
            {
                return;
            }
            if (keyInput.isSkillSpecial())
            {
                showSkillKongGe();
            }
            if (keyInput.isUseSutra())
            {
                showSkillFaBao();
            }
            if (keyInput.isSkill1())
            {
                showSkill(1);
            }
            if (keyInput.isSkill2())
            {
                showSkill(2);
            }
            if (keyInput.isSkill3())
            {
                showSkill(3);
            }
            if (keyInput.isSkill4())
            {
                showSkill(4);
            }
            if (keyInput.isSkill5())
            {
                showSkill(5);
            }
        }
        
        public function stopMoveLeft():void
        {
            isLeft = false;
            if (!isRight)
            {
                if (!isAttacking() && !isInSky() && !isIdle() && !isStiff())
                {
                    setAction("idle");
                }
                if (!isCanMoveWhenAttack())
                {
                    velocity.x = 0;
                }
            }
            else
            {
                bbdc.turnRight();
            }
        }
        
        public function stopMoveRight():void
        {
            isRight = false;
            if (!isLeft)
            {
                if (!isAttacking() && !isInSky() && !isIdle() && !isStiff())
                {
                    setAction("idle");
                }
                if (!isCanMoveWhenAttack())
                {
                    velocity.x = 0;
                }
            }
            else
            {
                bbdc.turnLeft();
            }
        }
        
        public function beAttackDoing():void
        {
            resetGravity();
            addBeAttackEffect();
        }
        
        public function getPet():BasePet
        {
            return myPet;
        }
        
        public function getPlayer():PlayerDataVO
        {
            return player;
        }
        
        public function normalAttack():void
        {
        }
        
        public function setPlayer(param1:PlayerDataVO):void
        {
            player = param1;
        }
        
        public function setLostKeyboard():void
        {
            canNextAction = true;
        }
        
        override public function setAction(action:String):void
        {
            super.setAction(action);
            bbdc.setAction(action);
            if (action == "hurt")
            {
                bbdc.show();
                resetGravity();
                if (curAction == "hurt")
                {
                    bbdc.gotoAndPlay(1);
                }
            }
        }
        
        /**
         * 用于初始化角色属性和升级，升级前会移除属性buff增益、装备属性增益、被动技能增益
         * 之后会重新进行数值计算
         */
        public function upGrade():void
        {
            roleProperties.removeAllAttribEffect();
            roleProperties.removeAllEquipAndPassive();
            initAttribute();
        }
        
        public function initAttribute():void
        {
            //在子类中定义每级的血量，然后调用此函数初始化属性
            roleProperties.setFullState();
            roleProperties.initAll();
        }
        
        override public function addHurtNumber(vo:HitResultVO):void
        {
            super.addHurtNumber(vo);
            if (vo.isMiss || vo.isBingo)
            {
                return;
            }
            var gadgetVO:GameGadgetVO = new GameGadgetVO();
            gadgetVO.value = vo.hurt;
            gadgetVO.position = new Point(x, getCollideArea().top);
            switch (vo.hitType)
            {
                case HitType.PHYSICS:
                    gadgetVO.type = vo.isCrit ? GameGadgetType.NUM_HERO_CRIT_HURT_PHYSICS : GameGadgetType.NUM_HERO_HURT_PHYSICS;
                    break;
                case HitType.MAGIC:
                    gadgetVO.type = vo.isCrit ? GameGadgetType.NUM_HERO_CRIT_HURT_MAGIC : GameGadgetType.NUM_HERO_HURT_MAGIC;
                    break;
                case HitType.REAL:
                    gadgetVO.type = vo.isCrit ? GameGadgetType.NUM_HERO_CRIT_HURT_REAL : GameGadgetType.NUM_HERO_HURT_REAL;
                    break;
            }
            EventManager.getIns().dispatchEvent(GameEventType.ADD_GAME_GADGET, gadgetVO);
        }
        
        public function checkTransferDoor():Boolean
        {
            for each(var door:TransDoor in gc.pWorld.getTransferDoorArray())
            {
                if (door.visible && checkCollideTarget(door))
                {
                    return true;
                }
            }
            return false;
        }
        
        public function clearAllBullets():void
        {
            for each (var bullet:BaseBullet in magicBulletArray)
            {
                bullet.setDisable();
                TweenMax.killChildTweensOf(bullet);
                bullet.destroy();
            }
            magicBulletArray = [];
        }
        
        override public function destroy():void
        {
            if (bbdc)
            {
                bbdc.destroy();
            }
            if (isGXP)
            {
                isGXP = false;
                turnToNormal();
            }
            resetGravity();
            velocity.y = 0;
            keyInput.cancelRun();
            invincibleCount = 0;
            if (curAddEffect)
            {
                curAddEffect.destroy();
                curAddEffect = null;
            }
            clearAllBullets();
            removeFromParent();
            if (curMagicWeapon)
            {
                curMagicWeapon.destroy();
                curMagicWeapon = null;
            }
            if (getPet())
            {
                getPet().destroy();
                myPet = null;
            }
            isReadyToDestroy = true;
        }
        
        public function refreshTitle():void
        {
            var _loc5_:* = null;
            var _loc6_:String = null;
            var _loc3_:* = undefined;
            var disp:DisplayObject;
            if (!player)
            {
                return;
            }
            disp = getChildByName("Role_Title");
            if (disp)
            {
                removeChild(disp);
            }
            if (player.wearEquip.title)
            {
                var title:String = player.wearEquip.title.equipId;
                if (title != "gfcstx")
                {
                    _loc3_ = ResUtil.getImageBitmap("role_title_" + title);
                    _loc3_.x = -55;
                    _loc3_.y = -90;
                    _loc3_.name = "Role_Title";
                    addChild(_loc3_);
                }
                else
                {
                    _loc3_ = ResUtil.getNewObj("role_title_" + title);
                    _loc3_.x = -125;
                    _loc3_.y = -220;
                    _loc3_.name = "Role_Title";
                    addChild(_loc3_);
                }
                disp = getChildByName("exceedPow");
                if (disp)
                {
                    if (getChildIndex(disp) < getChildIndex(_loc3_))
                    {
                        swapChildren(disp, _loc3_);
                    }
                }
            }
            return;
            /*_loc1_ = getChildByName("Godeffect");
            if (_loc1_)
            {
                removeChild(_loc1_);
            }
            _loc5_ = player.getEquipAppearance().zbfj;
            _loc6_ = player.getEquipAppearance().zbwq;
            _loc1_ = getChildByName("spEffect_1");
            if (_loc1_)
            {
                removeChild(_loc1_);
            }
            if (getPlayer().wearEquip.decoration && getPlayer().wearEquip.decoration.equipId == "hy")
            {
                (_loc4_ = ResUtil.getNewObj("spEffect_1")).x = 0;
                _loc4_.y = 60;
                _loc4_.scaleX = 0.8;
                _loc4_.scaleY = 0.8;
                _loc4_.alpha = 0.7;
                _loc4_.name = "spEffect_1";
                addChildAt(_loc4_, 0);
            }*/
        }
        
        /**
         * 刷新外观
         */
        public function refreshAppearance():void
        {
            //在子类中重写关于bbdc的刷新
            refreshAlliance();
            refreshTitle();
        }
        
        public function changePet():void
        {
            if (getPet())
            {
                getPet().destroy();
            }
            initPet();
        }
        
        public function changeMagicWeapon():void
        {
            if (getCurMagicWeapon())
            {
                getCurMagicWeapon().destroy();
            }
            initMagicWeapon();
        }
        
        protected function initPet():void
        {
            if (!getPlayer())
            {
                return;
            }
            var petVO:PetDataVO = getPlayer().findCurrentPet();
            if (petVO)
            {
                petVO.setDoWhenLevelUp(doWhenLevelUp);
                petVO.setDoWhenChangeState(doWhenChangeState);
                myPet = addPetByPi(petVO);
                myPet.x = x;
                myPet.y = y - 100;
                gc.gameScene.addChild(myPet);
            }
        }
        
        protected function initMagicWeapon():void
        {
            return;
            /*if (!getPlayer())
            {
                return;
            }
            var vo:EquipmentVO = getPlayer().getCurEquipByType("zbfb");
            if (vo)
            {
                switch (vo.equipId)
                {
                    case "xhhl":
                        curMagicWeapon = new MagicBottle(this);
                        break;
                    case "kyl":
                        curMagicWeapon = new MagicLeaf(this);
                        break;
                    case "qyj":
                        curMagicWeapon = new MagicSword(this);
                        break;
                    case "hyzzs":
                        curMagicWeapon = new MagicUmbrella(this);
                        break;
                    case "zjld":
                        curMagicWeapon = new MagicRing(this);
                        break;
                    case "xhmt":
                        curMagicWeapon = new MagicPearl(this);
                        break;
                    case "syl":
                        curMagicWeapon = new MagicLeaf2(this);
                        break;
                    case "lxj":
                        curMagicWeapon = new MagicSword2(this);
                        break;
                    case "hywjs":
                        curMagicWeapon = new MagicUmbrella2(this);
                        break;
                    case "zsTimer":
                        curMagicWeapon = new MagicTimer(this);
                        break;
                    case "mdhf":
                        curMagicWeapon = new MagicFlag(this);
                        break;
                    case "jyhl":
                        curMagicWeapon = new MagicFlower(this);
                        break;
                    case "qljfb":
                        curMagicWeapon = new MagicBigBottle(this);
                        break;
                    case "tjbg":
                        curMagicWeapon = new MagicBagua(this);
                        break;
                    case "lxfb":
                        curMagicWeapon = new MagicLXFB(this);
                        break;
                    case "sxfb":
                        curMagicWeapon = new MagicSXFB(this);
                        break;
                    case "yxfb":
                        curMagicWeapon = new MagicYXFB(this);
                        break;
                    case "stlp":
                        curMagicWeapon = new MagicLing(this);
                        break;
                    case "hxyb":
                        curMagicWeapon = new MagicYuban(this);
                        break;
                }
                if (curMagicWeapon)
                {
                    gc.gameScene.addChild(curMagicWeapon);
                }
            }*/
        }
        
        protected function setPet():void
        {
            updatePet();
        }
        
        protected function showSkill(skillIndex:int = 0):void
        {
        }
        
        protected function showSkillKongGe():void
        {
            if (roleProperties.energy >= 100 && !isGXP)
            {
                turnToGXP();
                var eff:AnimationClip = AnimationManager.getAnimationClip("releaseWS");
                eff.loopType = AnimationLoopType.REMOVE_WHEN_END;
                eff.x = getLocalCollideCenter().x;
                eff.y = 0;
                effectContainer.addChild(eff);
            }
        }
        
        protected function showSkillFaBao():void
        {
            if (curMagicWeapon)
            {
                curMagicWeapon.useSkill();
            }
        }
        
        protected function updateOther():void
        {
            if (isGXP)
            {
                if (_framer % 4 == 0)
                {
                    shadowEffect();
                }
                if (roleProperties.energy > 0)
                {
                    roleProperties.energy -= 0.33;
                }
                else
                {
                    turnToNormal();
                }
            }
            if (getPlayer())
            {
                roleProperties.update();
                //executeKeyCode();
                stepKeyInput();
            }
        }
        
        protected function myKeyDown(param1:String):*
        {
        }
        
        protected function turnToNormal():void
        {
            isGXP = false;
            gravity = 1.5;
            horizonSpeed = int(int(horizonSpeed / 1.5));
            horizonRunSpeed = int(int(horizonRunSpeed / 1.5));
            jumpPower = int(jumpPower / 1.5);
        }
        
        protected function updateEquip():void
        {
            /*var bm:* = undefined;
            var eq:* = null;
            if (player)
            {
                if (curAddEffect)
                {
                    if (equipCounter == 0)
                    {
                        if (curAddEffect.getBuffByName(BaseAddEffect.LXFB_BUFF))
                        {
                            trace("lx losehp");
                            reduceHp(0.01 * roleProperties.hpMax, false);
                        }
                        if (curAddEffect.getBuffByName(BaseAddEffect.SXFB_BUFF))
                        {
                            trace("sx losemp");
                            reduceMp(0.01 * roleProperties.mpMax);
                        }
                    }
                }
                eq = player.getCurEquipByType("zbsp");
                if (eq)
                {
                    if (eq.equipId == "zhhz" || eq.equipId == "hy")
                    {
                        for each (bm in gc.pWorld.getMonsterArray())
                        {
                            if (bm.isFly && !bm.isBoss)
                            {
                                if (!bm.isInvincible() && !bm.isDead())
                                {
                                    if (AUtils.GetDisBetweenTwoObj(bm, this) <= 300)
                                    {
                                        bm.addCurAddEffect([{
                                            "name": BaseAddEffect.SLEEP,
                                            "time": gc.frameClips * 0.5
                                        }]);
                                    }
                                }
                            }
                        }
                    }
                    if (eq.equipId == "bxhy" || eq.equipId == "hy")
                    {
                        if (Number(getTimer()) - lastHurtTime >= 10000)
                        {
                            if (equipCounter == 0)
                            {
                                cureHp((roleProperties.mpMax * roleProperties.mpHeal + roleProperties.hpMax * roleProperties.hpHeal) / 40000);
                            }
                        }
                    }
                }
            }*/
        }
        
        /**
         * 原用于刷新联盟头衔，现用于显示名字
         */
        private function refreshAlliance():void
        {
            var content:String;
            content = getPlayer().playerName ? getPlayer().playerName : getPlayer().getRoleName();
            if (getPlayer())
            {
                if (!allianceBitmap)
                {
                    allianceBitmap = TextUtil.getTextBitmap(content);
                    allianceBitmap.x = -allianceBitmap.width / 2;
                    addChild(allianceBitmap);
                }
                allianceBitmap.y = collideBox.top - 30;
                if (player.wearEquip.title)
                {
                    allianceBitmap.y -= 30;
                }
            }
            else if (!allianceBitmap)
            {
                allianceBitmap = TextUtil.getTextBitmap(content);
                allianceBitmap.x = -allianceBitmap.width / 2;
                allianceBitmap.y = collideBox.top - 30;
                addChild(allianceBitmap);
            }
        }
        
        override public function turnLeft():void
        {
            if (isAttacking() || isBeAttacking())
            {
                return;
            }
            super.turnLeft();
        }
        
        override public function turnRight():void
        {
            if (isAttacking() || isBeAttacking())
            {
                return;
            }
            super.turnRight();
        }
        
        public function stepKeyInput():void
        {
            if (isDead())
            {
                return;
            }
            if (keyInput.isWalkLeft())
            {
                turnLeft();
                moveLeft();
            }
            else
            {
                stopMoveLeft();
            }
            if (keyInput.isWalkRight())
            {
                turnRight();
                moveRight();
            }
            else
            {
                stopMoveRight();
            }
            if (!isBeAttacking() && !isAttacking() && !isStatic())
            {
                if (isRunning())
                {
                    if (!isJump())
                    {
                        setAction("run");
                    }
                }
                else
                {
                    if (!isJump())
                    {
                        setAction("walk");
                    }
                }
            }
            if (!isAttacking() && !isBeAttacking() && canNextAction)
            {
                if (keyInput.isJumpDown())
                {
                    canNextAction = false;
                    getDownStair();
                }
                if (keyInput.isJump())
                {
                    canNextAction = false;
                    jump();
                }
            }
            if (keyInput.isPressUp())
            {
                if (checkTransferDoor())
                {
                    gc.pWorld.getBaseLevelListener().keyBoardDownForW(this);
                }
            }
            stepSkillKey();
        }
        
        protected function keyInputHandler(evt:KeyboardEvent):void
        {
            if (evt.type == KeyboardEvent.KEY_UP)
            {
                canNextAction = true;
            }
        }
    }
}
